<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>华联商场后台管理系统</title>
    <link rel="stylesheet"  type="text/css"  href="/lib/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/custom.css">
    <link rel="stylesheet" href="/css/iosOverlay.css">
    <link rel="stylesheet" href="/css/prettify.css">
    <link rel="stylesheet"   href="/css/goodsclass.css">

    <style>
        thead tr{
            background-color: rgba(102,102,102,1);
            color: #fff;
        }
        table{
            background: #FFFFFF;
            border: 1px solid #CCCCCC;
            border-radius: 2px;
        }
        tbody tr:nth-child(odd){
            background-color: #FAFAFA;
        }
        input[type=checkbox]{
            width: 14px;
            height: 14px;

        }
    </style>
</head>
<body>
<div class="right">
    <div class="page-header ">
        <div class="row" style="padding: 0 22px;text-align: center">
            <form  name="form1" class="search_wrapper" action = "{:url('admin/category/select')}" method = "post" >
                <select class="select" name="grade" value="">
                    <option  value="" >按分类查找</option>
                    <option  value="0" >一级分类</option>
                    <option  value="1" >二级分类</option>
                    <option  value="2" >三级分类</option>
                </select>
                <input type="text" class="search" placeholder="请输入关键字 如：牛奶" name = "categroy_name">
                <button type="submit" id="submit"  class="btn btn-info ">搜索</button>
                <a href="{:url('category/insert')}" class="btn btn-info ">新增</a>
                <a href="{:url('admin/category/index')}" class="btn btn-default ">刷新</a>
            </form>
        </div>
    </div>
            <div class="row">
                <table class="table table-hover  good_item">
                    <thead>
                        <tr>
                            <td class="col-xs-2">名称</td>
                            <td class="col-xs-2">商品级别</td>
                            <td class="col-sm-2">图片</td>
                            <td class="col-sm-2">操作</td>
                        </tr>
                    </thead>
                    <tbody>
                    {volist name = 'list' id = 'value'}
                    <tr >
                        <input type="text" hidden class="id" name="id" value="{$value.id}">
                        <input type="text" hidden class="goodtype1" name="type1" value="">
                        <input type="text" hidden class="goodtype2" name="type2" value="">
                        <input type="text" hidden class="type" value="{$value.grade}"/>
                        <td class="name">{$value.categroy_name} </td>
                        <td >
                            {if $value.grade  == '1'}
                            一级分类
                            {elseif $value.grade == '2'}
                            二级分类
                            {else}
                            三级分类
                            {/if}
                        </td>
                        <td><img src="{$value.image}" class="image" ></td>
                        <td>
                            <button type="submit" class="btn btn-info editbtn"  data-toggle="modal" data-target="#editmodel">编辑</button>
                            {if $value.is_use == '0'}
                                <a href="{:url('category/delete', ['type' => $value.grade, 'id' => $value.id])}" class="btn btn-danger">删除</a>
                            {else}
                                <a href="{:url('category/recovery', ['type' => $value.grade,'id' => $value.id, 'pid' => $value.pid])}" class="btn btn-warning">恢复</a>
                            {/if}
                        </td>
                    </tr>
                    {if !empty($value.min)} 
                        {volist name = 'value.min' id = 'valu'}
                            <tr>
                                <input type="text" hidden name="id"  class="id" value="{$valu.id}">
                                <input type="text" hidden class="type" value="{$valu.grade}"/>
                                <td class="name">{$valu.categroy_name} </td>
                                <td class="type">
                                    {if $valu.grade  == '1'}
                                    一级分类
                                    {elseif $valu.grade == '2'}
                                    二级分类
                                    {else}
                                    三级分类
                                    {/if}
                                </td>
                                <td><img src="{$valu.image}" class="image" ></td>
                                <td>
                                <button type="submit" class="btn btn-info editbtn"  data-toggle="modal" data-target="#editmodel">编辑</button>
                                    {if $valu.is_use == '0'}
                                    <a href="{:url('category/delete', ['type' => $valu.grade, 'id' => $valu.id])}" class="btn btn-danger">删除</a>
                                    {else}
                                    <a href="{:url('category/recovery', ['type' => $valu.grade,'id' => $valu.id, 'pid' => $valu.pid])}" class="btn btn-warning">恢复</a>
                                    {/if}
                                </td>
                            </tr>
                            {if !empty($valu.three)}
                            {volist name = 'valu.three' id = 'va'}
                                <tr>
                                    <input type="text" name="id" class="id" hidden value="{$va.id}">
                                    <td class="name">{$va.categroy_name} </td>
                                    <input type="text" hidden class="goodtype1"  value="">
                                    <input type="text" hidden class="goodtype2"  value="">
                                    <input type="text" hidden class="type" value="{$va.grade}"/>
                                    <td class="type">
                                        {if $va.grade  == '1'}
                                        一级分类
                                        {elseif $va.grade == '2'}
                                        二级分类
                                        {else}
                                        三级分类
                                        {/if}
                                    </td>
                                    <td><img src="{$va.image}" class="image" ></td>
                                    <td>
                                    <button type="button" class="btn btn-info editbtn"  data-toggle="modal" data-target="#editmodel1">编辑</button>
                                        {if $va.is_use == '0'}
                                        <a href="{:url('category/delete', ['type' => $va.grade, 'id' => $va.id])}" class="btn btn-danger">删除</a>
                                        {else}
                                        <a href="{:url('category/recovery', ['type' => $va.grade,'id' => $va.id, 'pid' => $va.pid])}" class="btn btn-warning">恢复</a>
                                        {/if}
                                </td>
                                </tr>
                            {/volist}
                            {/if}
                        {/volist}
                        {/if}
                    {/volist}
                   </tbody>
                </table>
              {$list->render()}
            </div>

    <!--编辑modelstart-->
        <div class="modal fade" id="editmodel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">修改分类</h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" method="post" action="{:url('category/update')}">
                            <div class="form-group">
                                <label  class="col-xs-4 control-label">修改分类名:</label>
                                <div class="col-xs-6">
                                    <input type="text" class="form-control" name="categroy_name" id="name">
                                </div>
                                <input type="text" style="visibility: hidden" name="type" id="type">
                                <input type="text" style="visibility:hidden" name="id" id="id">
                            </div>
                            <div class="form-group">
                                <div class="col-xs-offset-4 col-xs-4">
                                    <button type="submit" class="btn btn-danger">确认修改</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    <!--编辑modelend-->
    <div class="modal fade" id="editmodel1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel1">修改分类</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" enctype="multipart/form-data" action="{:url('category/update')}" method="post" >
                        <div class="form-group">
                            <label  class="col-xs-4 control-label">修改分类名:</label>
                            <div class="col-xs-6">
                                <input type="text" class="form-control" name="categroy_name" id="name1">
                            </div>
                            <input type="text"  name="type" hidden id="type1">
                            <input type="text" name="id" id="id1" hidden>
                        </div>
                        <div class="form-group">
                            <label  class="col-xs-4 control-label">选择图片:</label>
                            <div class="col-xs-6">
                                <input type="file"  name="img"   id="img">
                            </div>
                        </div>
                      <!--  <div class="form-group">
                            <label  class="col-xs-4 control-label">分类规格1:</label>
                            <div class="col-xs-6">
                                <input type="text"  class="form-control" name="spec_name1"   id="typeName1">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-xs-4 control-label">分类规格2:</label>
                            <div class="col-xs-6">
                                <input type="text"  class="form-control" name="spec_name2"   id="typeName2">
                            </div>
                        </div>-->
                        <div class="form-group">
                            <div class="col-xs-offset-4 col-xs-4">
                                <button type="submit" class="btn btn-danger" id="bok">确认修改</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
            </div>
    </div>
<script src="/lib/jquery/jquery.min.js"></script>
<script src="/lib/bootstrap/js/bootstrap.min.js"></script>
<script src="/js/iosOverlay.js"></script>
<script src="/lib/plug/spin.min.js"></script>
<script src="/lib/plug/prettify.js"></script>
<script src="/js/method.js"></script>
<script src="/js/goodsclass.js"></script>
<script>
    $("#submit").click(function(){
        var val=$("select[name=grade]").val();
        var val1=$(".search").val();

        if(!val && !val1){
            iosOverlay({
                text: "请输入搜索内容!",
                duration: 2e3,
                icon: "../../images/cross.png"
            });
            return false;
        }
    });
</script>
</body>
</html>